<template>
  <hips-view sub-header-fixed>
    <hips-nav-bar
      slot="header"
      title="社会分享类"
      :back-button="{
        showLeftArrow: true,
      }"
      @nav-bar-back-click="$router.back()"
    />
    <demo-block title="share">
      <hips-button @click="shareFuc">
        调用分享插件分享
      </hips-button>
    </demo-block>

    <demo-block title="shareIM">
      <hips-button @click="shareIMFuc">
        发送富文本消息至 IM
      </hips-button>
    </demo-block>

    <demo-block title="shareImage">
      <hips-button @click="shareImageFuc">
        分享本地图片
      </hips-button>
    </demo-block>
  </hips-view>
</template>

<script>
import BasicView from '@/mixin/basic-view';
import { Button } from '@hips/vue-ui';
import { Share } from '@hips/plugin-vue-jssdk';

const { share, shareIM, shareImage } = Share;

export default {
  components: {
    [Button.name]: Button,
  },
  mixins: [ BasicView ],
  data() {
    return {};
  },
  methods: {
    shareFuc() {
      share({
        title: '测试',
        summary: '测试描述',
        redirectUrl: 'https://www.baidu.com',
        image: 'https://www.baidu.com/1.png',
      })
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    shareIMFuc() {
      shareIM({
        title: '测试',
        summary: '测试描述',
        redirectUrl: 'https://www.baidu.com',
        image: 'https://www.baidu.com/1.png',
      })
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    shareImageFuc() {
      shareImage(
        '/data/data/com.hand.hippiusRC/cache/tmp_group_qrcode_25747615611547603040.jpg',
      )
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
  },
};
</script>

<style lang="stylus"></style>
